package com.example.dao;

import com.example.mapper.generator.TeamPoMapper;
import com.example.mapper.generator.TeamStudentPoMapper;
import com.example.mapper.generator.po.TeamPo;
import com.example.mapper.generator.po.TeamStudentPo;
import com.example.mapper.generator.po.TeamStudentPoExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class TeamDao {
    @Autowired
    TeamStudentPoMapper teamStudentPoMapper;
    @Autowired
    TeamPoMapper teamPoMapper;
    public List<Long> getTeamIdsByStudentId(Long studentId){
        TeamStudentPoExample example = new TeamStudentPoExample();
        TeamStudentPoExample.Criteria criteria = example.createCriteria();
        criteria.andStudentIdEqualTo(studentId);
        List<TeamStudentPo> pos = teamStudentPoMapper.selectByExample(example);
        return pos.stream().map(TeamStudentPo::getTeamId).toList();
    }
    public TeamPo getTeamById(Long id){
        return teamPoMapper.selectByPrimaryKey(id);
    }
}
